package View.ClienteView;

import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;

import javax.swing.DefaultComboBoxModel;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.border.TitledBorder;

import Controller.ClienteController.ClienteController;
import Entidade.Cliente;
import View.EstadoView.EstadoConsultaView;
import View.PaisView.PaisConsultaView;
import framework.component.field.TTextField;
import framework.mvc.GenericView;

public class ClienteView extends GenericView<Cliente> {
	private static final long serialVersionUID = -7823708716196421639L;
	private TTextField textNome;
	private TTextField textField_2;
	private TTextField textField_3;
	private TTextField textFantasia;
	private TTextField textField_5;
	private TTextField Codigo;
	private TTextField textField_7;
	private TTextField textField_8;
	private TTextField textField_9;
	private TTextField textField_10;
	private TTextField textField_11;
	private TTextField textField_12;
	private TTextField textField_13;
	private TTextField textField_14;
	private JLabel lblBairro;
	private TTextField textField_15;
	private TTextField textField_16;
	private TTextField textField_17;
	private JLabel lblNewLabel_1;
	private JLabel lblNoAgencia;
	private JLabel lblCtaCorrente;
	private JLabel lblEndereo_1;
	private JLabel lblBairro_1;
	private JLabel lblEstado;
	private JLabel lblCidade;
	private JLabel lblCep_1;
	private JLabel lblGrupoVencimento;
	private JLabel lblCadastro;
	private JLabel lblFiado;
	private JLabel label_1;
	private TTextField textField_1;
	private TTextField textField_6;
	private TTextField textField_18;
	private TTextField textField_19;
	private TTextField textField_20;
	private TTextField textField_21;
	private TTextField textField_22;
	private TTextField textField_23;
	private TTextField textField_24;
	private TTextField textField_25;
	private TTextField textField_26;
	private JPanel panel;
	private JLabel lblNewLabel_2;
	private JLabel lblDataLimiteDe;
	private JLabel lblValorDoLimite;
	private JLabel lblCrdito;
	private TTextField textField_28;
	private TTextField textField_29;
	private TTextField textField_30;
	private TTextField textField_31;
	private JLabel lblSituaoDoCliente;
	private JLabel lblDataValor;
	private JLabel lblDataValor_1;
	private JLabel lblAtrasoMdio;
	private JLabel lblMaiorAtrasoHstorico;
	private JLabel lblCrditoUtilizado;
	private JLabel lblCrditoUtilizado_1;
	private JLabel lblCrditosPrdatados;
	private JButton button_2;
	private JCheckBox checkBox;
	private JButton btnNewButton;

	public ClienteView() {
		super(new ClienteController());
		setResizable(false);
		setFont(new Font("Verdana", Font.PLAIN, 12));
		setTitle("Fox Empresarial - Cadastro de Clientes");
		setSize(new Dimension(522, 474));

		JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
		tabbedPane.setFont(new Font("Verdana", Font.PLAIN, 11));

		JButton button_1 = new JButton("Cancelar");
		button_1.setName("cancelar");

		JButton button = new JButton("Salvar");
		button.setName("salvar");
		GroupLayout groupLayout = new GroupLayout(getContentPane());
		groupLayout
				.setHorizontalGroup(groupLayout
						.createParallelGroup(Alignment.LEADING)
						.addGroup(
								groupLayout
										.createSequentialGroup()
										.addGroup(
												groupLayout
														.createParallelGroup(
																Alignment.LEADING)
														.addGroup(
																groupLayout
																		.createSequentialGroup()
																		.addGap(351)
																		.addComponent(
																				button)
																		.addGap(8)
																		.addComponent(
																				button_1))
														.addGroup(
																groupLayout
																		.createSequentialGroup()
																		.addContainerGap()
																		.addComponent(
																				tabbedPane)))
										.addContainerGap()));
		groupLayout.setVerticalGroup(groupLayout.createParallelGroup(
				Alignment.LEADING).addGroup(
				groupLayout
						.createSequentialGroup()
						.addContainerGap()
						.addComponent(tabbedPane, GroupLayout.PREFERRED_SIZE,
								397, GroupLayout.PREFERRED_SIZE)
						.addPreferredGap(ComponentPlacement.RELATED)
						.addGroup(
								groupLayout
										.createParallelGroup(Alignment.LEADING)
										.addComponent(button)
										.addComponent(button_1))
						.addContainerGap(35, Short.MAX_VALUE)));

		JLayeredPane layeredPane = new JLayeredPane();
		tabbedPane.addTab("Geral", null, layeredPane, null);

		JLabel lblNewLabel = new JLabel("C\u00F3digo");
		lblNewLabel.setBounds(10, 15, 46, 14);
		layeredPane.add(lblNewLabel);

		Codigo = new TTextField();
		Codigo.setName("IdCliente");
		Codigo.setBounds(149, 9, 86, 20);
		layeredPane.add(Codigo);
		Codigo.setEditable(false);
		Codigo.setColumns(10);
		JLabel label_4 = new JLabel("Fantasia:");
		label_4.setBounds(10, 44, 45, 14);
		layeredPane.add(label_4);

		textFantasia = new TTextField();
		textFantasia.setBounds(149, 38, 324, 20);
		layeredPane.add(textFantasia);
		textFantasia.setName("FantasiaCliente");
		textFantasia.setColumns(10);

		JLabel label = new JLabel("Nome:");
		label.setBounds(10, 73, 31, 14);
		layeredPane.add(label);

		textNome = new TTextField();
		textNome.addFocusListener(new FocusAdapter() {
			@Override
			public void focusGained(FocusEvent arg0) {
				if (textNome.getText().trim().equals("")) {
					textNome.setText(textFantasia.getText());
				}
			}
		});
		textNome.setBounds(149, 67, 324, 20);
		layeredPane.add(textNome);
		textNome.setName("NomeCliente");
		textNome.setColumns(10);

		JLabel lblEstadoCidade = new JLabel("Estado / Cidade:");
		lblEstadoCidade.setBounds(10, 102, 86, 14);
		layeredPane.add(lblEstadoCidade);

		JLabel lblEndereo = new JLabel("Endere\u00E7o:");
		lblEndereo.setBounds(10, 131, 49, 14);
		layeredPane.add(lblEndereo);

		JLabel label_5 = new JLabel("Complemento:");
		label_5.setBounds(10, 160, 69, 14);
		layeredPane.add(label_5);

		textField_5 = new TTextField();
		textField_5.setBounds(149, 154, 325, 20);
		layeredPane.add(textField_5);
		textField_5.setName("ComplementoCliente");
		textField_5.setColumns(10);

		JLabel lblNmero = new JLabel("N\u00FAmero:");
		lblNmero.setBounds(10, 189, 86, 14);
		layeredPane.add(lblNmero);

		textField_7 = new TTextField();
		textField_7.setName("EstadoCliente");
		textField_7.setColumns(10);
		textField_7.setBounds(149, 96, 63, 20);
		layeredPane.add(textField_7);

		textField_8 = new TTextField();
		textField_8.setName("EnderecoCliente");
		textField_8.setColumns(10);
		textField_8.setBounds(149, 125, 324, 20);
		layeredPane.add(textField_8);

		JLabel lblCep = new JLabel("CEP:");
		lblCep.setName("CEPCliente");
		lblCep.setBounds(10, 218, 75, 14);
		layeredPane.add(lblCep);

		JLabel lblPas = new JLabel("Pa\u00EDs:");
		lblPas.setBounds(10, 247, 46, 14);
		layeredPane.add(lblPas);

		textField_9 = new TTextField();
		textField_9.setName("NumeroCliente");
		textField_9.setColumns(10);
		textField_9.setBounds(149, 183, 63, 20);
		layeredPane.add(textField_9);

		textField_10 = new TTextField();
		textField_10.setName("CEPCliente");
		textField_10.setColumns(10);
		textField_10.setBounds(149, 212, 133, 20);
		layeredPane.add(textField_10);

		textField_11 = new TTextField();
		textField_11.setName("ComplementoCliente");
		textField_11.setColumns(10);
		textField_11.setBounds(149, 241, 277, 20);
		layeredPane.add(textField_11);

		JLabel label_2 = new JLabel("Email:");
		label_2.setBounds(10, 305, 28, 14);
		layeredPane.add(label_2);

		textField_2 = new TTextField();
		textField_2.setBounds(149, 299, 324, 20);
		layeredPane.add(textField_2);
		textField_2.setName("EmailCliente");
		textField_2.setColumns(10);

		JLabel lblTelefones = new JLabel("Telefones:");
		lblTelefones.setBounds(10, 276, 69, 14);
		layeredPane.add(lblTelefones);

		JLabel lblTipoPessoa = new JLabel("Pessoa:");
		lblTipoPessoa.setBounds(10, 334, 69, 14);
		layeredPane.add(lblTipoPessoa);

		JComboBox comboBox = new JComboBox();
		comboBox.setModel(new DefaultComboBoxModel(new String[] {
				"Pessoa Fisica", "Pessoa J\u00FAridica" }));
		comboBox.setName("PessoaCliente");
		comboBox.setBounds(149, 328, 95, 20);
		layeredPane.add(comboBox);

		textField_12 = new TTextField();
		textField_12.setBounds(222, 96, 86, 20);
		layeredPane.add(textField_12);
		textField_12.setColumns(10);

		textField_13 = new TTextField();
		textField_13.setBounds(378, 96, 95, 20);
		layeredPane.add(textField_13);
		textField_13.setColumns(10);

		textField_14 = new TTextField();
		textField_14.setName("BairroCliente");
		textField_14.setBounds(332, 183, 141, 20);
		layeredPane.add(textField_14);
		textField_14.setColumns(10);

		lblBairro = new JLabel("Bairro:");
		lblBairro.setBounds(276, 189, 46, 14);
		layeredPane.add(lblBairro);

		JLabel lblCxpostal = new JLabel("Cx.Postal:");
		lblCxpostal.setBounds(292, 218, 57, 14);
		layeredPane.add(lblCxpostal);

		textField_15 = new TTextField();
		textField_15.setName("CaixaPostalCliente");
		textField_15.setBounds(354, 212, 119, 20);
		layeredPane.add(textField_15);
		textField_15.setColumns(10);

		textField_3 = new TTextField();
		textField_3.setBounds(149, 270, 105, 20);
		layeredPane.add(textField_3);
		textField_3.setName("TelefoneCliente");
		textField_3.setColumns(10);

		textField_16 = new TTextField();
		textField_16.setBounds(275, 270, 86, 20);
		layeredPane.add(textField_16);
		textField_16.setColumns(10);

		textField_17 = new TTextField();
		textField_17.setBounds(387, 270, 86, 20);
		layeredPane.add(textField_17);
		textField_17.setColumns(10);

		button_2 = new JButton("...");
		button_2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				// CidadeConsultaView cidadeview = new CidadeConsultaView();
				// cidadeview.abrir();
				EstadoConsultaView cidadeview = new EstadoConsultaView();
				cidadeview.abrir();

			}
		});
		button_2.setBounds(318, 93, 31, 23);
		layeredPane.add(button_2);

		btnNewButton = new JButton("...");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				PaisConsultaView paisview = new PaisConsultaView();
				paisview.abrir();
			}
		});
		btnNewButton.setBounds(442, 238, 31, 23);
		layeredPane.add(btnNewButton);

		JLayeredPane layeredPane_1 = new JLayeredPane();
		tabbedPane.addTab("Cobran\u00E7a", null, layeredPane_1, null);

		lblNewLabel_1 = new JLabel("No. Banco:");
		lblNewLabel_1.setBounds(10, 18, 65, 14);
		layeredPane_1.add(lblNewLabel_1);

		lblNoAgencia = new JLabel("No. Agencia:");
		lblNoAgencia.setBounds(10, 50, 65, 14);
		layeredPane_1.add(lblNoAgencia);

		lblCtaCorrente = new JLabel("Cta. Corrente:");
		lblCtaCorrente.setBounds(10, 82, 71, 14);
		layeredPane_1.add(lblCtaCorrente);

		lblEndereo_1 = new JLabel("Endere\u00E7o:");
		lblEndereo_1.setBounds(10, 114, 65, 14);
		layeredPane_1.add(lblEndereo_1);

		lblBairro_1 = new JLabel("Bairro:");
		lblBairro_1.setBounds(10, 146, 46, 14);
		layeredPane_1.add(lblBairro_1);

		lblEstado = new JLabel("Estado:");
		lblEstado.setBounds(10, 178, 46, 14);
		layeredPane_1.add(lblEstado);

		lblCidade = new JLabel("Cidade:");
		lblCidade.setBounds(10, 210, 71, 14);
		layeredPane_1.add(lblCidade);

		lblCep_1 = new JLabel("CEP:");
		lblCep_1.setBounds(10, 242, 46, 14);
		layeredPane_1.add(lblCep_1);

		lblGrupoVencimento = new JLabel("Grupo Vencimento:");
		lblGrupoVencimento.setBounds(10, 274, 99, 14);
		layeredPane_1.add(lblGrupoVencimento);

		lblCadastro = new JLabel("Cadastro: ");
		lblCadastro.setBounds(10, 306, 65, 14);
		layeredPane_1.add(lblCadastro);

		lblFiado = new JLabel("Fiado:");
		lblFiado.setBounds(10, 338, 46, 14);
		layeredPane_1.add(lblFiado);

		textField_6 = new TTextField();
		textField_6.setBounds(129, 12, 65, 20);
		layeredPane_1.add(textField_6);
		textField_6.setColumns(10);

		textField_18 = new TTextField();
		textField_18.setColumns(10);
		textField_18.setBounds(129, 44, 65, 20);
		layeredPane_1.add(textField_18);

		textField_19 = new TTextField();
		textField_19.setBounds(129, 76, 65, 20);
		layeredPane_1.add(textField_19);
		textField_19.setColumns(10);

		textField_20 = new TTextField();
		textField_20.setName("EnderecoClienteCobranca");
		textField_20.setBounds(129, 108, 290, 20);
		layeredPane_1.add(textField_20);
		textField_20.setColumns(10);

		textField_21 = new TTextField();
		textField_21.setName("BairroClienteCobranca");
		textField_21.setColumns(10);
		textField_21.setBounds(129, 140, 290, 20);
		layeredPane_1.add(textField_21);

		textField_22 = new TTextField();
		textField_22.setColumns(10);
		textField_22.setBounds(129, 172, 290, 20);
		layeredPane_1.add(textField_22);

		textField_23 = new TTextField();
		textField_23.setColumns(10);
		textField_23.setBounds(129, 204, 280, 20);
		layeredPane_1.add(textField_23);

		textField_24 = new TTextField();
		textField_24.setName("CEPClienteCobranca");
		textField_24.setColumns(10);
		textField_24.setBounds(129, 236, 290, 20);
		layeredPane_1.add(textField_24);

		textField_25 = new TTextField();
		textField_25.setColumns(10);
		textField_25.setBounds(129, 268, 290, 20);
		layeredPane_1.add(textField_25);

		textField_26 = new TTextField();
		textField_26.setColumns(10);
		textField_26.setBounds(129, 300, 290, 20);
		layeredPane_1.add(textField_26);

		checkBox = new JCheckBox("");
		checkBox.setBounds(129, 334, 97, 23);
		layeredPane_1.add(checkBox);

		JLayeredPane layeredPane_2 = new JLayeredPane();
		tabbedPane.addTab("Conv\u00EAnio", null, layeredPane_2, null);

		label_1 = new JLabel("CPF/CNPJ:");
		label_1.setBounds(32, 306, 52, 14);
		layeredPane_2.add(label_1);

		textField_1 = new TTextField();
		textField_1.setName("CPF_CNPJCliente");
		textField_1.setColumns(10);
		textField_1.setBounds(112, 306, 324, 20);
		layeredPane_2.add(textField_1);

		panel = new JPanel();
		panel.setBorder(new TitledBorder(null, "Conv\u00EAnio",
				TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel.setBounds(20, 11, 304, 160);
		layeredPane_2.add(panel);

		lblNewLabel_2 = new JLabel("C\u00F3digo do Conv\u00EAnio:");

		lblDataLimiteDe = new JLabel("Data Limite de Cr\u00E9dito:");

		lblValorDoLimite = new JLabel("Valor do Limite:");

		lblCrdito = new JLabel("Cr\u00E9dito Utilizado:");

		textField_28 = new TTextField();
		textField_28.setColumns(10);

		textField_29 = new TTextField();
		textField_29.setColumns(10);

		textField_30 = new TTextField();
		textField_30.setColumns(10);

		textField_31 = new TTextField();
		textField_31.setColumns(10);
		GroupLayout gl_panel = new GroupLayout(panel);
		gl_panel.setHorizontalGroup(gl_panel
				.createParallelGroup(Alignment.LEADING)
				.addGroup(
						gl_panel.createSequentialGroup()
								.addContainerGap()
								.addGroup(
										gl_panel.createParallelGroup(
												Alignment.LEADING)
												.addComponent(lblNewLabel_2)
												.addComponent(lblDataLimiteDe)
												.addComponent(lblValorDoLimite)
												.addComponent(lblCrdito))
								.addGap(31)
								.addGroup(
										gl_panel.createParallelGroup(
												Alignment.LEADING)
												.addComponent(
														textField_31,
														GroupLayout.PREFERRED_SIZE,
														123,
														GroupLayout.PREFERRED_SIZE)
												.addComponent(
														textField_30,
														GroupLayout.PREFERRED_SIZE,
														123,
														GroupLayout.PREFERRED_SIZE)
												.addComponent(
														textField_29,
														GroupLayout.PREFERRED_SIZE,
														123,
														GroupLayout.PREFERRED_SIZE)
												.addComponent(
														textField_28,
														GroupLayout.PREFERRED_SIZE,
														123,
														GroupLayout.PREFERRED_SIZE))
								.addContainerGap(18, Short.MAX_VALUE)));
		gl_panel.setVerticalGroup(gl_panel.createParallelGroup(
				Alignment.LEADING).addGroup(
				gl_panel.createSequentialGroup()
						.addGap(22)
						.addGroup(
								gl_panel.createParallelGroup(Alignment.LEADING)
										.addComponent(lblNewLabel_2,
												Alignment.TRAILING)
										.addComponent(textField_28,
												Alignment.TRAILING,
												GroupLayout.PREFERRED_SIZE,
												GroupLayout.DEFAULT_SIZE,
												GroupLayout.PREFERRED_SIZE))
						.addPreferredGap(ComponentPlacement.RELATED)
						.addGroup(
								gl_panel.createParallelGroup(Alignment.LEADING)
										.addComponent(lblDataLimiteDe,
												Alignment.TRAILING)
										.addComponent(textField_29,
												Alignment.TRAILING,
												GroupLayout.PREFERRED_SIZE,
												GroupLayout.DEFAULT_SIZE,
												GroupLayout.PREFERRED_SIZE))
						.addPreferredGap(ComponentPlacement.UNRELATED)
						.addGroup(
								gl_panel.createParallelGroup(Alignment.LEADING)
										.addComponent(lblValorDoLimite,
												Alignment.TRAILING)
										.addComponent(textField_30,
												Alignment.TRAILING,
												GroupLayout.PREFERRED_SIZE,
												GroupLayout.DEFAULT_SIZE,
												GroupLayout.PREFERRED_SIZE))
						.addPreferredGap(ComponentPlacement.RELATED)
						.addGroup(
								gl_panel.createParallelGroup(Alignment.LEADING)
										.addComponent(lblCrdito,
												Alignment.TRAILING)
										.addComponent(textField_31,
												Alignment.TRAILING,
												GroupLayout.PREFERRED_SIZE,
												GroupLayout.DEFAULT_SIZE,
												GroupLayout.PREFERRED_SIZE))
						.addContainerGap(12, Short.MAX_VALUE)));
		panel.setLayout(gl_panel);

		JLayeredPane layeredPane_3 = new JLayeredPane();
		tabbedPane.addTab("Estat\u00EDstica", null, layeredPane_3, null);

		lblSituaoDoCliente = new JLabel("Situa\u00E7\u00E3o do Cliente:");
		lblSituaoDoCliente.setBounds(10, 28, 96, 14);
		layeredPane_3.add(lblSituaoDoCliente);

		lblDataValor = new JLabel("Data / Valor Limite de Cr\u00E9dito:");
		lblDataValor.setBounds(10, 70, 163, 14);
		layeredPane_3.add(lblDataValor);

		lblDataValor_1 = new JLabel("Data / Valor da Ultima Compra:");
		lblDataValor_1.setBounds(10, 112, 163, 14);
		layeredPane_3.add(lblDataValor_1);

		lblAtrasoMdio = new JLabel("Atraso M\u00E9dio:");
		lblAtrasoMdio.setBounds(10, 154, 96, 14);
		layeredPane_3.add(lblAtrasoMdio);

		lblMaiorAtrasoHstorico = new JLabel("Maior Atraso H\u00EDstorico");
		lblMaiorAtrasoHstorico.setBounds(10, 196, 129, 14);
		layeredPane_3.add(lblMaiorAtrasoHstorico);

		lblCrditoUtilizado = new JLabel("Cr\u00E9dito Utilizado:");
		lblCrditoUtilizado.setBounds(10, 238, 96, 14);
		layeredPane_3.add(lblCrditoUtilizado);

		lblCrditoUtilizado_1 = new JLabel(
				"Cr\u00E9dito Utilizado c/ Pr\u00E9-Datados:");
		lblCrditoUtilizado_1.setBounds(10, 280, 163, 14);
		layeredPane_3.add(lblCrditoUtilizado_1);

		lblCrditosPrdatados = new JLabel("Cr\u00E9ditos Pr\u00E9-Datados:");
		lblCrditosPrdatados.setBounds(10, 322, 129, 14);
		layeredPane_3.add(lblCrditosPrdatados);

		JLayeredPane layeredPane_4 = new JLayeredPane();
		tabbedPane.addTab("Faturamento", null, layeredPane_4, null);

		JLayeredPane layeredPane_5 = new JLayeredPane();
		tabbedPane.addTab("Informa\u00E7\u00F5es", null, layeredPane_5, null);

		JLayeredPane layeredPane_6 = new JLayeredPane();
		tabbedPane.addTab("Outros", null, layeredPane_6, null);
		getContentPane().setLayout(groupLayout);
	}
}
